<?php
$load=5;
$GLOBALS['配置']['jm']=5;
include_once(dirname(__FILE__).'/lib/conf.php');
need_login();


$btda=jd(BT_SEND('获取网站域名绑定二级目录信息', array('id'=>$user['siteid'])));
$dirs[]='/';
foreach($btda['dirs'] as $e) $dirs[]='/'.$e;


$data['dirs']=$dirs;



$dfile=R('dfile');
$bm=R('bm');
if(!empty($dfile)){
	if(!in_array($dfile,$dirs)) redirect('?emsg=解压失败,目录不存在');
	$rdir=$user['path'];
	if($dfile=='/') $dfiles=$rdir;
	else $dfiles=$rdir.$dfile;
	//print_r($user);
	$ret=jd(BT_SEND('文件.列表', 
			array(
				'search'=>'unzip.zip',
				'path'=>$rdir,
			)
		));
		//print_r($ret);
	$ret=explode(';',$ret['FILES'][0]);
//	die($ret[0]);
	if($ret[0]!='unzip.zip') redirect('?emsg=解压失败, unzip.zip 文件不存在');

	$ret=jd(BT_SEND('文件.解压', 
			array(
				'sfile'=>$rdir.'/unzip.zip',
				'dfile'=>$dfiles,
				'type'=>'zip',
				'coding'=>($bm=='GBK')?'GBK':'UTF-8',
				'password'=>'',
			)
		));
	if(!$ret['status'])  redirect('?emsg='.urlencode($ret['msg']));
	redirect('?smsg='.urlencode('已添加解压任务至列队,预计需要10秒-10分钟,请10分钟后查看是否成功,如果不成功请联系客服解决'));
	
}





$data['smsg']=$_GET['smsg'];
$data['emsg']=$_GET['emsg'];
//print_r($btda);


$data['ipage']='unzip';
$data['title']='解压文件';
load_view('head',$data);
load_view('unzip',$data);
load_view('foot');